package com.example.tb_base.base_viewbinding_activity_fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.viewbinding.ViewBinding
import com.example.tb_base.base_activity_fragment.BaseFragment

/**
 * 基于ViewBinding的Fragment基类，统一处理布局加载、WindowInsets适配等通用逻辑。
 * 子类只需实现抽象方法即可快速搭建自己的Fragment。
 */
abstract class BaseViewBindingFragment<V : ViewBinding> : BaseFragment() {
    protected val binding: V? by lazy {
        obtainViewBinding()
    }

    override fun createView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return binding?.root
    }

    protected abstract fun obtainViewBinding(): V?
}